<template>
	<view class="container">
		<uni-list>
			<uni-list-item v-for="route in routes" :key="route.path" :title="route.path"
				:note="route.style.navigationBarTitleText" clickable @click="editRoute(route)" />
		</uni-list>
		<button @click="addRoute">添加路由</button>
	</view>
</template>

<script>
	import routesData from '@/api/routes.json'

	export default {
		data() {
			return {
				routes: []
			}
		},
		created() {
			this.loadRoutes()
		},
		methods: {
			loadRoutes() {
				this.routes = routesData.routes
			},
			addRoute() {
				uni.navigateTo({
					url: '/pages/admin/route-manage/edit'
				})
			},
			editRoute(route) {
				uni.navigateTo({
					url: `/pages/admin/route-manage/edit?path=${route.path}`
				})
			}
		}
	}
</script>